package com.shadow.mall.address.controller;

import com.shadow.mall.address.api.AddressApi;
import com.shadow.mall.address.dao.ProvinceDAO;
import com.shadow.mall.address.domain.dto.AddressDTO;
import com.shadow.mall.address.domain.entity.ProvinceDO;
import com.shadow.mall.address.domain.query.AddressQuery;
import com.shadow.mall.common.core.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 *
 * @version 1.0
 */
@RestController
@RequestMapping("/address")
public class AddressController {

    @Autowired
    private ProvinceDAO provinceDAO;
    @Autowired
    private AddressApi addressApi;

    @GetMapping("/listProvinces")
    public List<ProvinceDO> listProvinces() {
        List<ProvinceDO> provinceDOList = provinceDAO.list();
        return provinceDOList;
    }

    @RequestMapping("/queryAddress")
    public JsonResult<AddressDTO> queryAddress(@RequestBody AddressQuery query){
        JsonResult<AddressDTO> addressDTOJsonResult = addressApi.queryAddress(query);
        return addressDTOJsonResult;
    }

}